package com.che.software.testato.domain.entity;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

import com.che.software.testato.domain.enumeration.Operator;
import com.che.software.testato.domain.enumeration.SelectionTypes;
import com.che.software.testato.domain.enumeration.SelectiveArea;
import com.che.software.testato.util.jsf.faces.LocaleUtil;

/**
 * Class representing a selection.
 * 
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @copyright Che Software.
 * @license GNU General Public License.
 * @see Serializable
 * @since August, 2011.
 * 
 *        This file is part of Testato.
 * 
 *        Testato is free software: you can redistribute it and/or modify it
 *        under the terms of the GNU General Public License as published by the
 *        Free Software Foundation, either version 3 of the License, or (at your
 *        option) any later version.
 * 
 *        Testato is distributed in the hope that it will be useful, but WITHOUT
 *        ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *        FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *        for more details.
 * 
 *        You should have received a copy of the GNU General Public License
 *        along with Testato. If not, see <http://www.gnu.org/licenses/>.
 * 
 *        Testato's logo is a creation of Arrioch
 *        (http://arrioch.deviantart.com/) and it's distributed under the terms
 *        of the Creative Commons License.
 */
public class Selection implements Serializable {

	/**
	 * Constants.
	 */
	private static final long serialVersionUID = -2679374279690384801L;

	/**
	 * Members.
	 */
	private List<SelectiveArea> costValueAreas, fitRiskAreas;
	private Operator operator;
	private SelectionTypes selectionType;
	private String operatorString, selectionTypeString;

	/**
	 * Gets a readable label of cost value areas list.
	 * 
	 * @author Clement HELIOU (clement.heliou@che-software.com).
	 * @return the resulting string.
	 * @since August, 2011.
	 */
	public String getCostValueAreasLabel() {
		StringBuilder sBuilder = new StringBuilder();
		Iterator<SelectiveArea> it = costValueAreas.iterator();
		while (it.hasNext()) {
			sBuilder.append(LocaleUtil.getSelectiveAreaTranslation(it.next()));
			if (it.hasNext()) {
				sBuilder.append("/");
			}
		}
		return sBuilder.toString();
	}

	/**
	 * Gets a readable label of fit risk areas list.
	 * 
	 * @author Clement HELIOU (clement.heliou@che-software.com).
	 * @return the resulting string.
	 * @since August, 2011.
	 */
	public String getFitRiksAreasLabel() {
		StringBuilder sBuilder = new StringBuilder();
		Iterator<SelectiveArea> it = fitRiskAreas.iterator();
		while (it.hasNext()) {
			sBuilder.append(LocaleUtil.getSelectiveAreaTranslation(it.next()));
			if (it.hasNext()) {
				sBuilder.append("/");
			}
		}
		return sBuilder.toString();
	}

	/**
	 * Gets the translated operator label.
	 * 
	 * @author Clement HELIOU (clement.heliou@che-software.com).
	 * @return the resulting string.
	 * @since August, 2011.
	 */
	public String getOperatorLabel() {
		return LocaleUtil.getOperatorTranslation(operator);
	}

	/**
	 * Gets the translated selection type label.
	 * 
	 * @author Clement HELIOU (clement.heliou@che-software.com).
	 * @return the resulting string.
	 * @since August, 2011.
	 */
	public String getSelectionLabel() {
		return LocaleUtil.getSelectionTranslation(selectionType);
	}

	/**
	 * Gets the translated selection type explanation label.
	 * 
	 * @author Clement HELIOU (clement.heliou@che-software.com).
	 * @return the resulting string.
	 * @since August, 2011.
	 */
	public String getSelectionExplanationLabel() {
		return LocaleUtil.getSelectionExplanationTranslation(selectionType);
	}

	/**
	 * Getter for the private field value costValueAreas.
	 * 
	 * @return the costValueAreas field value.
	 */
	public List<SelectiveArea> getCostValueAreas() {
		return costValueAreas;
	}

	/**
	 * Setting a value to the costValueAreas field.
	 * 
	 * @param costValueAreas the value to set.
	 */
	public void setCostValueAreas(List<SelectiveArea> costValueAreas) {
		this.costValueAreas = costValueAreas;
	}

	/**
	 * Getter for the private field value fitRiskAreas.
	 * 
	 * @return the fitRiskAreas field value.
	 */
	public List<SelectiveArea> getFitRiskAreas() {
		return fitRiskAreas;
	}

	/**
	 * Setting a value to the fitRiskAreas field.
	 * 
	 * @param fitRiskAreas the value to set.
	 */
	public void setFitRiskAreas(List<SelectiveArea> fitRiskAreas) {
		this.fitRiskAreas = fitRiskAreas;
	}

	/**
	 * Getter for the private field value operator.
	 * 
	 * @return the operator field value.
	 */
	public Operator getOperator() {
		return operator;
	}

	/**
	 * Setting a value to the operator field.
	 * 
	 * @param operator the value to set.
	 */
	public void setOperator(Operator operator) {
		this.operator = operator;
	}

	/**
	 * Getter for the private field value selectionType.
	 * 
	 * @return the selectionType field value.
	 */
	public SelectionTypes getSelectionType() {
		return selectionType;
	}

	/**
	 * Setting a value to the selectionType field.
	 * 
	 * @param selectionType the value to set.
	 */
	public void setSelectionType(SelectionTypes selectionType) {
		this.selectionType = selectionType;
	}

	/**
	 * Getter for the private field value operatorString.
	 * 
	 * @return the operatorString field value.
	 */
	public String getOperatorString() {
		return operatorString;
	}

	/**
	 * Setting a value to the operatorString field.
	 * 
	 * @param operatorString the value to set.
	 */
	public void setOperatorString(String operatorString) {
		this.operatorString = operatorString;
	}

	/**
	 * Getter for the private field value selectionTypeString.
	 * 
	 * @return the selectionTypeString field value.
	 */
	public String getSelectionTypeString() {
		return selectionTypeString;
	}

	/**
	 * Setting a value to the selectionTypeString field.
	 * 
	 * @param selectionTypeString the value to set.
	 */
	public void setSelectionTypeString(String selectionTypeString) {
		this.selectionTypeString = selectionTypeString;
	}
}